/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package persistence;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

/**
 * This class is a JPA entity and is used to represent an assistant
 * as it will be stored in the database
 * 
 * @author Amigos do Noddy
 *
 */
@Entity
@Table(name = "ASSISTANT", schema = "APP")
//@NamedQueries({@NamedQuery(name = "Assistant.findByRefidperson", query = "SELECT a FROM Assistant a WHERE a.refidperson = :refidperson")})
@PrimaryKeyJoinColumn(name = "REFIDPERSON", referencedColumnName = "IDPERSON")
@DiscriminatorValue("Assistente")
public class Assistant extends Person implements Serializable {
    private static final long serialVersionUID = 1L;
    
    /*@Id
    @Column(name = "REFIDPERSON", nullable = false)
    private Integer refidperson;
    @JoinColumn(name = "REFIDPERSON", referencedColumnName = "IDPERSON", insertable = false, updatable = false)
    @OneToOne
    private Person person;*/
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "assistant")
    private Collection<Assignment> assignmentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refidpersonAssistant")
    private Collection<Faq> faqCollection;
    
    /*@OneToMany(cascade = CascadeType.ALL, mappedBy = "refidpersonAuthor")
    private Collection<Comment> commentCollection;*/

    /**
     * Default constructor
     */
    public Assistant() {
    }

    /*public Assistant(Integer refidperson) {
        this.refidperson = refidperson;
    }

    public Integer getRefidperson() {
        return refidperson;
    }

    public void setRefidperson(Integer refidperson) {
        this.refidperson = refidperson;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }*/

    /**
     * Gets the list of assignments to this assistant
     */
    public Collection<Assignment> getAssignmentCollection() {
        return assignmentCollection;
    }

    /**
     * Sets the list of assignments for this assistant
     * @param assignmentCollection list of assignments
     */
    public void setAssignmentCollection(Collection<Assignment> assignmentCollection) {
        this.assignmentCollection = assignmentCollection;
    }

    /**
     * Gets the list of faqs of this assistant
     * @return list of faqs of this assistant
     */
    public Collection<Faq> getFaqCollection() {
        return faqCollection;
    }

    /**
     * Sets the list of faqs of this assistant
     * @param faqCollection
     */
    public void setFaqCollection(Collection<Faq> faqCollection) {
        this.faqCollection = faqCollection;
    }

    /*@Override
    public int hashCode() {
        int hash = 0;
        hash += (refidperson != null ? refidperson.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Assistant)) {
            return false;
        }
        Assistant other = (Assistant) object;
        if ((this.refidperson == null && other.refidperson != null) || (this.refidperson != null && !this.refidperson.equals(other.refidperson))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.Assistant[refidperson=" + refidperson + "]";
    }

	/*public void setCommentCollection(Collection<Comment> commentCollection) {
		this.commentCollection = commentCollection;
	}

	public Collection<Comment> getCommentCollection() {
		return commentCollection;
	}*/

}
